package com.jingshui.Service.imp;

import com.alibaba.fastjson.JSONObject;
import com.jingshui.Dao.OrderDao;
import com.jingshui.Entity.User;
import com.jingshui.Service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import orm.base.Ex.BaseServiceEx;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * Created by ashin on 2017/9/29.
 */

@Service
@Scope("prototype")
public class OrderServiceImp extends BaseServiceEx implements OrderService {

    @Autowired
    OrderDao orderDao;

    @Override
    public void init() {
        super.init(orderDao);
    }


    public JSONObject reserve(Map map, HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        map.put("uId", user.getId());
//        map.put("uId", "16");
        map.put("orderId",getOrderId());
        int ret = orderDao.insertp(map);
        if (ret != -1) {
            return this.codeMess(sCode, "新增成功");
        }
        return this.codeMess(eCode, "新增失败");
    }

    @Override
    public JSONObject queryOrderInfo(Map map, HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
//        map.put("uId","16");
        map.put("uId",user.getId());
        return this.codeData(orderDao.queryOrderInfo(map));
    }

    @Override
    public JSONObject queryAdmin(Map map) throws Exception {
        return this.codeData(orderDao.queryAdmin(map));
    }

}
